- 
                Notifications
    You must be signed in to change notification settings 
- Fork 35
new function to import seismic tomographies from NetCDF files #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
      
        
          +47
        
        
          −5
        
        
          
        
      
    
  
Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    small test file
new function to import tomographies from NetCDF with tests
| Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/data_import.jl b/src/data_import.jl
index e983f30..d6cbbdf 100644
--- a/src/data_import.jl
+++ b/src/data_import.jl
@@ -366,15 +366,15 @@ function tomo_2_GeoData(filename::String; vel_type::String = "vs")
 
     # Extract the variables
     depth = data["depth"][:]
-    lon   = data["longitude"][:]
-    lat   = data["latitude"][:]
-    vel   = data[vel_type][:,:,:]
+    lon = data["longitude"][:]
+    lat = data["latitude"][:]
+    vel = data[vel_type][:, :, :]
 
     # create lon, lat, depth grid
     Lon, Lat, Depth = lonlatdepth_grid(lon, lat, .- depth)
 
     # create GeoData struct
-    Tomo_data = GeoData(Lon, Lat, Depth, (vel=vel,))
+    Tomo_data = GeoData(Lon, Lat, Depth, (vel = vel,))
 
     return Tomo_data
-end
\ No newline at end of file
+end
diff --git a/test/test_GMT.jl b/test/test_GMT.jl
index 9528ef3..d50cee6 100644
--- a/test/test_GMT.jl
+++ b/test/test_GMT.jl
@@ -2,10 +2,10 @@ using Test
 using GeophysicalModelGenerator, GMT
 
 Topo = import_topo(lon = [8, 9], lat = [50, 51])
-@test sum(Topo.depth.val) ≈ 1076.7045 rtol = 1e-1
+@test sum(Topo.depth.val) ≈ 1076.7045 rtol = 1.0e-1
 
 Topo = import_topo([8, 9, 50, 51]);
-@test sum(Topo.depth.val) ≈ 1076.7045 rtol = 1e-1
+@test sum(Topo.depth.val) ≈ 1076.7045 rtol = 1.0e-1
 
 test_fwd = import_GeoTIFF("test_files/length_fwd.tif", fieldname = :forward)
 @test  maximum(test_fwd.fields.forward) ≈ 33.17775km
diff --git a/test/test_data_import.jl b/test/test_data_import.jl
index 3b71606..5223778 100644
--- a/test/test_data_import.jl
+++ b/test/test_data_import.jl
@@ -93,10 +93,10 @@ tomo_file = "test_files/test_tomo_data.nc"
 Tomo_data = tomo_2_GeoData(tomo_file)
 test_array = [i for i in 0:1:10]
 
-@test Tomo_data.lon.val[:,1,1] ≈ test_array
-@test Tomo_data.lat.val[1,:,1] ≈ test_array
-@test Tomo_data.depth.val[1,1,:] ≈ .- test_array
+@test Tomo_data.lon.val[:, 1, 1] ≈ test_array
+@test Tomo_data.lat.val[1, :, 1] ≈ test_array
+@test Tomo_data.depth.val[1, 1, :] ≈ .- test_array
 
 for i in eachindex(test_array)
-    @test Tomo_data.fields.vel[i,i,i] ≈ i
-end
\ No newline at end of file
+    @test Tomo_data.fields.vel[i, i, i] ≈ i
+end | 
              
                    boriskaus
  
              
              requested changes
              
                  
                    Jun 5, 2025 
                  
              
              
            
            
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
Few requests:
- Can you add this to the documentation as well (simply list the function)
- It seems that GMT tests are failing in a different part. Could you please fix those tests?
| The GMT test is now adapted and requested changes were made, but still some tests are failing | 
              
                    boriskaus
  
              
              approved these changes
              
                  
                    Jun 5, 2025 
                  
              
              
            
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
The new function reads tomographic models from NetCDF files and generates the corresponding GeoData structure. The function is tested with a small test.nc file.